﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WorkBasket.ExtensionFactory;
using WorkBasket.Areas.Design.Models;
using WorkBasket.Infrastructure;
using WorkBasket.Data.Repository;
using WorkBasket.Data.Entities;

namespace WorkBasket.Areas.Design.Controllers
{
    public class DesignController : Controller
    {

        private SOC _soc = new SOC(new MyContext());
        // GET: Design/Workflow
        public ActionResult Workflow(int Id)
        {
          
            DesignVM vm = new DesignVM();
            vm.Actions = ExtensionsHost.Extensions.Actions;
            vm.Controls = ExtensionsHost.Extensions.Controls;
            vm.Workflows = _soc.Workflows.Where(wf => wf.UnitID == Id);
            vm.UnitID = Id;
            return View(vm);
        }
        public ActionResult Form(int Id)
        {
            DesignVM vm = new DesignVM();
            vm.Actions = ExtensionsHost.Extensions.Actions;
            vm.Controls = ExtensionsHost.Extensions.Controls;
            vm.Workflows = _soc.Workflows.Where(wf => wf.UnitID == Id);
            vm.UnitID = Id;
            return View(vm);
        }

      [MyAuth(Roles = "Designer")]
        public ActionResult Index()
        {
            SOC soc = new SOC(new MyContext());

            IQueryable<Unit> Units = soc.Units.GetAll();


            return View(Units);
        }

    }
}